<?php

namespace App\Admin\Tools\Customer;

use App\Models\AdminUsersModel;
use Encore\Admin\Grid\Tools\AbstractTool;

class CustomerCreateTool extends AbstractTool
{
    /**
     * @inheritDoc
     */
    public function render(): string
    {
        $users = AdminUsersModel::query()
            ->leftJoin('admin_users_related', 'admin_users.id', '=', 'admin_users_related.user_id')
            ->select('user_id', 'name');
        if (!ISADMIN) {
            if (ISMAIN) $users->where('admin_users_related.main_id', USERID);
            else $users->where('admin_users_related.user_id', USERID);
        }
        $users = $users->get()->toArray();
        return view('customer.create', [
            'data' => $users
        ]);
    }
}
